package com.hengpeng.itfin.persist.impl;

import java.util.Date;

import org.springframework.stereotype.Repository;

import com.hengpeng.common.persist.AbstractDao;
import com.hengpeng.common.persist.entity.OperateLog;
import com.hengpeng.common.persist.entity.OperateLog.OperationType;
import com.hengpeng.itfin.persist.OperateLogDao;

/**
 * <pre>
 * 操作员的操作日志持久层实现
 * </pre>
 * @author CHARLES
 * @version 1.0, 2010-8-9
 */
@Repository
public class OperateLogDaoImpl extends AbstractDao<OperateLog> implements OperateLogDao
{

	private void operateLog(OperationType type, String userId, String entityName, String entityId, Date operateTime,
			String description)
	{
		OperateLog log = new OperateLog();
		log.setOperationType(type);
		log.setUserId(userId);
		log.setEntityName(entityName);
		log.setEntityId(entityId);
		log.setOperateTime(operateTime);
		log.setDescription(description);
		super.save(log);
	}

	public void operateLogDelete(String userId, String entityName, String entityId, Date operateTime, String description)
	{
		operateLog(OperationType.DELETE, userId, entityName, entityId, operateTime, description);
	}

	public void operateLogModify(String userId, String entityName, String entityId, Date operateTime, String description)
	{
		operateLog(OperationType.UPDATE, userId, entityName, entityId, operateTime, description);
	}

	public void operateLogSave(String userId, String entityName, String entityId, Date operateTime, String description)
	{
		operateLog(OperationType.CREATE, userId, entityName, entityId, operateTime, description);
	}
}
